<template>
    <div class="">
        <el-dialog title="编辑家庭纠纷" :visible.sync="dialog" width="40%" :before-close="dialogClose">
            <el-form ref="formData" :model="formData" label-width="100px">
				<el-form-item label="所属户档" prop="homeid">
				    <el-select v-model="formData.homeid" style="width: 100%;" placeholder="请选择所属户档">
				    	<el-option :label="item.header + '(' + item.sn + ')'" :value="item.id" v-for="(item, index) in Home"></el-option>
				    </el-select>
				</el-form-item>
				<el-form-item label="单位" prop="name">
				    <el-input v-model="formData.unit" placeholder="请输入乡/镇/街道/村/社区"></el-input>
				</el-form-item>
				<el-form-item label="户籍地址" prop="name">
				    <el-input v-model="formData.address" placeholder="请输入户籍地址"></el-input>
				</el-form-item>
				<el-form-item label="居住地址" prop="name">
				    <el-input v-model="formData.residence" placeholder="请输入居住地址"></el-input>
				</el-form-item>
				<el-row>
					<el-col :span="12">
						<el-form-item label="家庭人数" prop="name">
						    <el-input v-model="formData.person" placeholder="请输入共同生活家庭人数"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="双方关系" prop="phone">
						    <el-input v-model="formData.relationship" placeholder="请输入双方关系"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="家庭类型" prop="cate">
							<el-select v-model="formData.hometype" style="width: 100%;" placeholder="请选择家庭类型">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.homeType"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="纠纷类型" prop="culture">
							<el-select v-model="formData.disputetype" style="width: 100%;" placeholder="请选择纠纷类型">
								<el-option :label="item" :value="item" v-for="(item, index) in Site.dissolveType"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="一起居住" prop="idcard">
						   <el-select v-model="formData.together" style="width: 100%;" placeholder="请选择一起居住">
						   	<el-option label="是" :value="1"></el-option>
							<el-option label="否" :value="2"></el-option>
						   </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="是否化解" prop="sex">
							<el-select v-model="formData.result" style="width: 100%;" placeholder="请选择是否化解">
								<el-option label="是" :value="1"></el-option>
								<el-option label="否" :value="2"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>

				<el-form-item label="处置意见" prop="name">
				    <el-input type="textarea" autosize v-model="formData.opinion" placeholder="请输入处置意见"></el-input>
				</el-form-item>
				<el-form-item label="填报单位" prop="name">
				    <el-input v-model="formData.addunit" placeholder="请输入填报单位"></el-input>
				</el-form-item>
				<el-form-item label="备注" prop="name">
				    <el-input v-model="formData.remark" placeholder="请输入备注"></el-input>
				</el-form-item>
               
            	<el-form-item>
            		<el-button @click="dialogClose">取 消</el-button>
            		<el-button type="primary" @click="formSubmit">确 定</el-button>
            	</el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        data() {
			return {
				dialog: false,
				Home: [],
				Site: [],
				formData: {
					id: 0,
				}
			}
        },
		created() {
		},
		watch: {
			dialog () {
				if(!this.dialog) {
					this.clearFormData()
					this.$emit('getData')
				} else {
					this.getHome()
					this.getSite()
				}
			}
		},
        methods: {
			getHome () {
				this.$apiPost('House/getHome').then(res => {
					if(res.code == 1) {
						this.Home = res.data
					}
				})
			},
			getSite () {
				this.$apiPost('Index/getSiteFile').then(res => {
					if(res.code == 1) {
						this.Site = res.data
					}
				})
			},
			dialogClose(){
				this.$emit('dialogToggle')
			},
			clearFormData () {
				for(let i in this.formData){
					if(i == 'id') {
						this.formData[i] = 0
					} else {
						this.formData[i] = ''
					}
				}
			},
			// 保存编辑
			formSubmit() {
				this.$apiPost('Homedissolve/editData', this.formData).then(res => {
					if(res.code == 1) {
						this.$message(res.msg)
						this.dialogClose()
					} else {
						this.$message(res.msg)
					}
				})
			},
        }
    };
</script>
<style scoped>
	.mselect{
		width: 100%;
	}
	.mtdiv{
		margin-top: 10px;
		display: inline-block;
		width: 100%;
	}
	.mtdiv .mtdiv-v{
		float: left;
		width: 50%;
		margin-bottom: 5px;
		display: flex;
		align-items: center;
	}
	.mtdiv .mtdiv-v label{
		float: left;
		margin-right: 10px;
	}
	.mtdiv .el-input{
		float: left;
		width: 80%;
		margin: 5px 0;
	}
</style>
